<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2021.3.19
 * Time: 16:07
 */

class User {
    protected $name = 'unknown';
    protected $age;
    protected $sex;

    public function __construct($name = 'unknown',$age = 18,$sex  = 1)
    {
        $this->name = $name;
        $this->age = $age;
        $this->sex = $sex;
    }
}

$reflector = new ReflectionClass(User::class);
$constructors = $reflector->getConstructor();// 如果类无构造函数，那么返回一个 null
$parameters = $constructors->getParameters();


$defaultValue = $reflector->getDefaultProperties(); // 获取类的默认属性，属性值默认为 null

$endLine = $reflector->getEndLine(); // 获取类在php文件中 }的行数

$fieName = $reflector->getFileName();  // 返回文件名的 决定路径

$getName = $reflector->getName(); // 返回反射的类名

